<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('菜房入库列表')"/>
    <style>
        .fixed-table-toolbar .bs-bars {
            width: 100%;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">

        <div class="col-sm-12 search-collapse">
            <div class="btn-group " style="margin: 0px auto;display: table;" role="group">
                <button type="button" class="top-link btn btn-sm btn-white">当天任务</button>
                <button type="button" class="top-link btn-sm btn-white">入库</button>
                <button type="button" class="top-link btn-sm btn-primary">仓储</button>
                <button type="button" class="top-link btn-sm btn-white">出库</button>
            </div>

            <!--<hr class="mt5 mb5">-->

        </div>
        <div class="col-sm-12 search-collapse">

            <form id="formId">
                <div class="select-list">

                    <ul>
                        <li>
                            <h3 class="inline">仓储：</h3>
                        </li>
                        <input type="hidden" value="1" name="params[stock]"/>
                        <input type="hidden" th:value="${type}" name="params[cforderFor]"/>
                        </li>
                        <li class="select-time">
                            <label>入库时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime]" lay-key="1">
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"
                                   lay-key="2">
                        </li>

                        <li>
                            入库经手人：<input type="text" name="inputUser"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:ncInputCf:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:ncInputCf:remove')}]];
    var prefix = ctx + "system/ncInputCf";
    var datas = [[${@dict.getType('cforderType')}]];
    var cforderFor = [[${type}]];
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "菜房入库",
            toolbar: 'toolbar1',
            // queryParams: {params: {stock: 1,cforderFor:cforderFor}},
            queryParams: function queryParams(params) {
                params = $.extend(params, {params: {stock: 1, cforderFor: cforderFor}})
                var search = $.table.queryParams(params);
                return search;
            },
            striped: true,
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            showExport: false,
            showFooter: true,
            columns: [
                {
                    field: 'inputId',
                    title: '入库id',
                    visible: false
                }, {
                    title: '序号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    },
                    footerFormatter: function () {
                        return '合计'
                    }
                },
                {
                    field: 'ncorderCf.cforderCode',
                    title: '订单编号',
                    formatter: function (value, row, index) {
                        if (row.ncorderCf.isCheck == '1') {
                            return '--'
                        } else {
                            return row.ncorderCf.cforderCode
                        }

                    },
                    footerFormatter: function () {
                        return '-'
                    }

                }, {

                    field: 'piciCode',
                    title: '蔬菜批次',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'cropNameCn',
                    title: '作物名称',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'cropVarietiesCn',
                    title: '作物品种',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'teamCn',
                    title: '生产班组',
                    footerFormatter: function () {
                        return '-'
                    }

                },
                {
                    field: 'ncorderCf.cforderType',
                    title: '入库类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'inputAmout',
                    title: '入库数量（kg）',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table').bootstrapTable('getData'), function (index, item) {
                            count += item.inputAmout;
                        });
                        return count;

                    }
                },
                {
                    field: 'leftAmount',
                    title: '剩余量',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table').bootstrapTable('getData'), function (index, item) {
                            count += item.leftAmount;
                        });
                        return count;

                    }
                },
                {
                    field: 'boxAmount',
                    title: '框数',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'inputTime',
                    title: '入库时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'inputUser',
                    title: '入库经手人',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },

                {
                    field: 'remark',
                    title: '备注',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="confirmOutput(\'' + row.inputId + '\')"><i class="fa fa-edit"></i>出库</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

        $('.top-link').click(function () {
            var index = $(this).index();
            switch (index) {
                case 0:
                    window.location.href = ctx + 'system/ncOrderCf/ncOrderCf-ordered?status=2&type=' + cforderFor;
                    return;
                case 1:
                    window.location.href = ctx + 'system/ncInputCf?type=' + cforderFor;
                    return;
                case 2:
                    window.location.reload();
                    return;
                case 3:
                    window.location.href = ctx + 'system/ncOuputCf?type=' + cforderFor;
                    return;
            }
        })
    });


    function confirmOutput(cforderId) {
        var url = ctx + "system/ncOuputCf/confirmOutputByStock/" + cforderId;
        $.modal.open("确认出库", url);
    }

    if(cforderFor == 1){
        setTitle("蔬菜整理间1-仓储",false)
    }else {
        setTitle("蔬菜整理间2-仓储",false)
    }
</script>
</body>
</html>